//
//  ViewController.m
//  KeyChain
//
//  Created by 牟华 on 17/1/9.
//  Copyright © 2017年 牟华. All rights reserved.
//

#import "ViewController.h"
#import "KeychainItemWrapper.h"
#import <Security/Security.h>
#import <CommonCrypto/CommonCryptor.h>
@interface ViewController ()

@property (weak, nonatomic) IBOutlet UILabel *label;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"myapp.com"]]) {
        
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"myapp.com"]];
    }
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    self.label.lineBreakMode = NSLineBreakByTruncatingHead;
    
    KeychainItemWrapper *keychain = [[KeychainItemWrapper alloc] initWithIdentifier:@"keychain" accessGroup:nil];
    
    NSString *accout = [keychain objectForKey:(id)kSecAttrAccount];
    NSString *pwd = [keychain objectForKey:(id)kSecValueData];
    NSLog(@"%@-------%@", accout, pwd);
    
    
//    [self.view mas_updateConstraints:^(MASConstraintMaker *make) {
//        make.left.mas_equalTo(self.label).offset(-10).priorityLow(10);
//        
//    }];
//    [self.view mas_remakeConstraints:^(MASConstraintMaker *make) {
//        
//    }];
//    [self.view mas_makeConstraints:^(MASConstraintMaker *make) {
//        
//    }];
    
    NSLayoutConstraint *constraint = [[NSLayoutConstraint alloc] init];
    constraint.priority = 100;
    
    
}

/**
 *  非对称加密算法RSA
 */

- (void)RSADemo {
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
